﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Aim2.Music {
    class Measure : Queue<string> {
        float totalNeeded;
        float currentElapsed;
        float BPM;

        public bool Full { get; set; }

        public Measure(float BPM)
            : base() {
                this.BPM = BPM;
                currentElapsed = 0;
                Full = true;
        }

        public new string Dequeue() {
            Full = false;
            return base.Dequeue();
        }

        public new void Enqueue(string s) {
            base.Enqueue(s);
            totalNeeded = (60f / BPM) / this.Count;
        }

        public bool IsNextReady(float elapsed) {
            currentElapsed += elapsed;
            if (currentElapsed < totalNeeded)
                return false;
            currentElapsed = 0;
            return true;
        }
    }
}
